import request from '@/utils/request'

// 获取用户详情
export const apiGetUserInfo = () => {
  return request({
    url: '/auth/getInfo',
    method: 'get',
    resField: 'obj'
  })
}
// 获取路由详情
export const apiGetRouterList = () => {
  return request({
    url: '/auth/getRouters',
    method: 'get',
  })
}

// 文件模板下载
export const apiDownTemplate = (url, loading) => {
  return request({
    url: url,
    method: 'get',
    responseType: 'blob',
    loading,
  })
}
// 导出
export const apiExport = (url, data, loading) => {
  return request({
    url: url,
    method: 'post',
    data,
    responseType: 'blob',
    loading,
  })
}

// 文件上传
export const apiUploadFile = (url, data, loading) => {
  return request({
    url: url,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: data,
    loading,
  })
}

// 文件下载
export const apiDownFile = (
  { url, params = {}, data = {}, method = 'get' },
  loading
) => {
  return request({
    url,
    method,
    params,
    data,
    responseType: 'blob',
    loading,
  })
}

// 通过模板配置获取列表接口
export const apiGetApiFunByTemplate = (
  { url, method, params, data, headers },
  loading
) => {
  return request({
    url,
    method,
    resField: 'data',
    params,
    data,
    loading,
    headers,
    autoUntie: false,
  })
}
